class EnentsController < ApplicationController
  before_action :set_enent, only: [:show, :edit, :update, :destroy]

  # GET /enents
  # GET /enents.json
  def index
    @enents = Enent.all
  end

  # GET /enents/1
  # GET /enents/1.json
  def show
  end

  # GET /enents/new
  def new
    @enent = Enent.new
  end

  # GET /enents/1/edit
  def edit
  end

  # POST /enents
  # POST /enents.json
  def create
    @enent = Enent.new(enent_params)

    respond_to do |format|
      if @enent.save
        format.html { redirect_to @enent, notice: 'Enent was successfully created.' }
        format.json { render :show, status: :created, location: @enent }
      else
        format.html { render :new }
        format.json { render json: @enent.errors, status: :unprocessable_entity }
      end
    end
  end

  # PATCH/PUT /enents/1
  # PATCH/PUT /enents/1.json
  def update
    respond_to do |format|
      if @enent.update(enent_params)
        format.html { redirect_to @enent, notice: 'Enent was successfully updated.' }
        format.json { render :show, status: :ok, location: @enent }
      else
        format.html { render :edit }
        format.json { render json: @enent.errors, status: :unprocessable_entity }
      end
    end
  end

  # DELETE /enents/1
  # DELETE /enents/1.json
  def destroy
    @enent.destroy
    respond_to do |format|
      format.html { redirect_to enents_url, notice: 'Enent was successfully destroyed.' }
      format.json { head :no_content }
    end
  end

  private
    # Use callbacks to share common setup or constraints between actions.
    def set_enent
      @enent = Enent.find(params[:id])
    end

    # Never trust parameters from the scary internet, only allow the white list through.
    def enent_params
      params.require(:enent).permit(:artist, :description, :price_low, :price_high, :event_date)
    end
end
